package com.solcoo.dao;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.solcoo.pojo.DiJiaJuan;

@Repository
public class DiJiaJuanDao {

	@Resource
	private SqlMapClient sqlMapClient;
	
	/*新增低价卷*/
	private static final String INSERT_TRDAEIN = "insertTradein";
	
    private static final String UPDATE_PAY = "updatePay";
    
    private static final String UPDATE_CANCEL = "updateCancel";
    
    private static final String SELECT_KEYONG_DJJ_SH_GR = "selectKeyongDjj";
    
    private static final String SELECT_DJJ_SH_GR = "selectDjjByShGr";
    
    private static final String SELECT_DJJ_SH = "selectDjjBySH";
    
    private static final String SELECT_DJJ_BY_ID = "selectDjjById";
    
    public void add(DiJiaJuan dijiadan) throws SQLException {
    	sqlMapClient.insert(INSERT_TRDAEIN, dijiadan);
    }
    
    public void updateYixiaofei(Map<String, Object> param ) throws SQLException {
		sqlMapClient.update(UPDATE_PAY, param);
	} 
    
    public void updateKeyong(Map<String, Object> param) throws SQLException {
		sqlMapClient.update(UPDATE_CANCEL, param);
	}
    
	public List<DiJiaJuan> queryAllKeyongDjj(Map<String, Object> param) throws SQLException {
        return sqlMapClient.queryForList(SELECT_KEYONG_DJJ_SH_GR, param);
    }
    
    public List<DiJiaJuan> queryAllDjjSh2Gr(Map<String, Object> param) throws SQLException {
        return sqlMapClient.queryForList(SELECT_DJJ_SH_GR, param);
    }
    
    public List<DiJiaJuan> queryAllDjjSh(int shanghuid) throws SQLException {
        return sqlMapClient.queryForList(SELECT_DJJ_SH, shanghuid);
    }
    
    public DiJiaJuan queryAllDjjById(int id) throws SQLException {
        return (DiJiaJuan)sqlMapClient.queryForObject(SELECT_DJJ_BY_ID, id);
    }
}
